import query from './atom/db/query';
import count from './atom/db/count';

declare const action_id: string;
declare const session_id: string;
declare const spaceid: string;

interface Message {
	criteria: object;
	page_size: number;
	page_no: number;
}

async function atom(msg: Message) {
	const systemid = '5981';
	const q = query(action_id, session_id, spaceid, systemid);

	q.prepare('exam_room', ['_id', 'exam_no', 'exam_room_id', 'teaching_building', 'belong_area', 'floor_no', 'classroom_type', 'max_intake_capacity', 'available', 'exam_id', 'classroom_id', 'house_number', 'fzno', 'scattergram', 'pic_path', 'department_no', 'department', 'house_name'], msg.criteria, msg.page_size, msg.page_no, []);

	const [t] = await q.exec();

	const c = count(action_id, session_id, spaceid, systemid);
	c.prepare('exam_room', msg.criteria);
	const [tc] = await c.exec();

	return { dataArray: t, count: tc };
}
